package com.kata.chapter6;

import java.io.UnsupportedEncodingException;

/**
 * 16 进制文件读取
 * Created by Solidsnake on 2014/11/20.
 */
public class HexFileReader implements IFileReader {
    private byte[] context = null;


    @Override
    public boolean hasBefore() {
        return false;
    }

    @Override
    public boolean hasAfter() {
        return true;
    }

    @Override
    public void before() {

    }

    @Override
    public void after() {
        System.out.println("正在转码...");
        try {
            this.context = "这是正常16进制文件内容!!".getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }

    @Override
    public byte[] read() {
        try {
            this.context = "这是未转吗PBF文档内容!!".getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return this.context;
    }

    @Override
    public byte[] getContext() {
        return this.context;
    }
}
